#pragma once
#include <iostream>
#include <string>
#include <vector>
#include <sys/fcntl.h>
#include <unistd.h>
using namespace std;
class Util
{
public:
    static bool StringSplit(const string &str, const string &sep, vector<string> &v)
    {
        size_t start = 0;
        while (start < str.size())
        {
            size_t pos = str.find(sep, start);
            if (pos == string::npos)
            {
                break;
            }
            v.push_back(str.substr(start, pos - start));
            start = pos + sep.size();
        }
        if (start < str.size())
        {
            v.push_back(str.substr(start));
        }
        return true;
    }
    static bool NonBlock(int fd)
    {
        int fl = fcntl(fd, F_GETFL);
        if (fl < 0)
        {
            return false;
        }
        fcntl(fd, F_SETFL, fl | O_NONBLOCK);
        return true;
    }
};